package com.rmondjone.face

import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.LinearLayoutManager
import com.bumptech.glide.Glide
import com.rmondjone.androidcamerademo.R
import com.rmondjone.face.ViewModel.FaceViewModel
import com.rmondjone.face.adapter.SymptomAdapter
import com.rmondjone.utils.applyCircle
import kotlinx.android.synthetic.main.frgment_suggest.recyclerview
import kotlinx.android.synthetic.main.frgment_sysptom.*
import java.io.File

/**
 * copyright：
 * @author：anthui creation date： .
 * @since: 1.0.0
 * @describe:
 */
class SymptomFragment : Fragment() {


    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

        return inflater.inflate(R.layout.frgment_sysptom, container, false)

    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        val get = ViewModelProviders.of(requireActivity()).get(FaceViewModel::class.java)
        Log.e("msg", "tag---------------- " + get.hashCode())

        get.faceConsultBean.value?.apply {

            var symptomAdapter = SymptomAdapter()

            recyclerview.apply {

                layoutManager = LinearLayoutManager(requireContext())
                adapter = symptomAdapter
            }
            symptomAdapter.setNewData(results)


            var tizhiName = tiaoli.tizhi_name

            if (TextUtils.isEmpty(tizhiName)) {
                layout_name.visibility = View.GONE
            } else {
                layout_name.visibility = View.VISIBLE
                tv_name.text = tizhiName
            }
            tv_content.text = tiaoli.changjianbiaoxian ?: ""

            if (get.filePath.isNotEmpty()) {
                Glide.with(this@SymptomFragment).load(File(get.filePath)).applyCircle().into(iv_pic)
            }


        }

    }
}